/**
 * API相关类型定义
 */

// 基础API响应类型
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
  success: boolean
  timestamp: number
}

// 分页响应类型
export interface PaginationResponse<T = any> {
  list: T[]
  total: number
  page: number
  pageSize: number
  totalPages: number
}

// 请求参数基础类型
export interface BaseParams {
  page?: number
  pageSize?: number
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
}

// 上传文件响应类型
export interface UploadResponse {
  url: string
  filename: string
  size: number
  type: string
}

// 登录请求类型
export interface LoginRequest {
  username: string
  password: string
  captcha?: string
}

// 登录响应类型
export interface LoginResponse {
  token: string
  refreshToken: string
  expires: number
  user: {
    id: number
    username: string
    email: string
    avatar?: string
    roles: string[]
  }
}

// 刷新token请求类型
export interface RefreshTokenRequest {
  refreshToken: string
}

// 用户信息更新请求类型
export interface UpdateUserRequest {
  email?: string
  avatar?: string
  nickname?: string
  phone?: string
}

// 修改密码请求类型
export interface ChangePasswordRequest {
  oldPassword: string
  newPassword: string
  confirmPassword: string
}

// 文件上传请求类型
export interface FileUploadRequest {
  file: File
  type?: string
  folder?: string
}

// 搜索请求类型
export interface SearchRequest extends BaseParams {
  keyword: string
  category?: string
  status?: string
  startDate?: string
  endDate?: string
}

// 批量操作请求类型
export interface BatchOperationRequest {
  ids: number[]
  action: 'delete' | 'enable' | 'disable' | 'export'
}

// 导出请求类型
export interface ExportRequest {
  format: 'excel' | 'csv' | 'pdf'
  filters?: Record<string, any>
  columns?: string[]
}

// 统计数据响应类型
export interface StatisticsResponse {
  total: number
  today: number
  thisWeek: number
  thisMonth: number
  growth: number
  trend: number[]
}

// 菜单项类型
export interface MenuItem {
  id: number
  name: string
  path: string
  icon?: string
  children?: MenuItem[]
  meta?: {
    title: string
    requiresAuth: boolean
    roles?: string[]
  }
}

// 权限类型
export interface Permission {
  id: number
  name: string
  code: string
  description: string
  type: 'menu' | 'button' | 'api'
  parentId?: number
  children?: Permission[]
}

// 角色类型
export interface Role {
  id: number
  name: string
  code: string
  description: string
  permissions: Permission[]
  status: 'active' | 'inactive'
  createdAt: string
  updatedAt: string
}

// 系统配置类型
export interface SystemConfig {
  siteName: string
  logo: string
  favicon: string
  description: string
  keywords: string
  contact: {
    email: string
    phone: string
    address: string
  }
  seo: {
    title: string
    description: string
    keywords: string
  }
}

// 通知类型
export interface Notification {
  id: number
  title: string
  content: string
  type: 'info' | 'success' | 'warning' | 'error'
  read: boolean
  createdAt: string
  link?: string
}

// 操作日志类型
export interface OperationLog {
  id: number
  userId: number
  username: string
  action: string
  module: string
  description: string
  ip: string
  userAgent: string
  createdAt: string
} 